package ${basePackage}.maker.generator.file;

import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

/**
 * @version ${version}
 * @Author ${author}
 * @Date ${createTime}
 * @注释 动静结合测试类
 */
public class FileGenerator {
    public static void main(String[] args) throws TemplateException, IOException {

    }

    public static void doGenerate(Object model) throws IOException, TemplateException {
        //静态文件生成
        //获取整个项目的根路径
        String projectPath = System.getProperty("user.dir");
        //System.out.println("projectPath = " + projectPath);
        //输入文件路径
        String inputPath=projectPath+ File.separator+"yuzi-generator-demo-projects"+ File.separator+ "acm-template";// todo 在不同的操作系统下，文件路径分隔符不同，这里使用File.separator来获取，windows下是\\，linux下是/
        //输出文件路径
        String outputPath=projectPath;
        //复制文件
        StaticFileGenerator.copyFileByHutool(inputPath,outputPath);

        //动态生成
        String dynamicInputPath=projectPath+File.separator+"yuzi-generator-maker"+File.separator+"src/main/resources/templates/MainTemplate.java.ftl";
        String dynamicOutputPath=projectPath+File.separator+"acm-template/src/com/yupi/acm/MainTemplate.java";
        DynamicFileGenerator.doGenerate(dynamicInputPath,dynamicOutputPath,model);
    }
}
